package com.rupertjones.globalcron.web.model;

import com.rupertjones.globalcron.domain.AuditLog;
import com.rupertjones.globalcron.domain.AuditLogType;

import java.util.Date;

/**
 * <p>&copy Rupert Jones 2012</p>
 *
 * @author rup
 */
public class DisplayableAuditLog {

    private static final int MESSAGE_MAX_LENGTH = 150;
    private AuditLog log = null;

    public DisplayableAuditLog(AuditLog log) {
        this.log = log;
    }

    public int getId() {
        return log.getId();
    }

    public AuditLogType getType() {
        return log.getType();
    }

    public Date getCreatedAt() {
        return log.getCreatedAt();
    }

    public String getUser() {
        return log.getUser();
    }

    public String getMessage() {
        return log.getMessage();
    }

    public String getLimitedMessage() {
        String message = getMessage();
        if (message.length() <= MESSAGE_MAX_LENGTH) {
            return message;
        } else {
            return message.substring(0, MESSAGE_MAX_LENGTH) + "...";
        }
    }
}
